Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[SoftAE] added new profiler sink

  • Loading branch information...
commit fe7d0ca9799c7fbf268a27177c64b2885433e031 1 parent cf68761
Geoffrey McRae authored January 28, 2012
10  xbmc/cores/AudioEngine/AESinkFactory.cpp
@@ -35,6 +35,7 @@
35 35
 #else
36 36
   #pragma message("NOTICE: No audio sink for target platform.  Audio output will not be available.")
37 37
 #endif
  38
+#include "Sinks/AESinkProfiler.h"
38 39
 
39 40
 void CAESinkFactory::ParseDevice(CStdString &device, CStdString &driver)
40 41
 {
@@ -55,7 +56,8 @@ void CAESinkFactory::ParseDevice(CStdString &device, CStdString &driver)
55 56
         driver == "WASAPI"      ||
56 57
         driver == "DIRECTSOUND" ||
57 58
 #endif
58  
-        false)
  59
+        driver == "PROFILER"
  60
+        )
59 61
       device = device.substr(pos + 1, device.length() - pos - 1);
60 62
     else
61 63
       driver.Empty();
@@ -91,6 +93,10 @@ IAESink *CAESinkFactory::Create(CStdString &device, AEAudioFormat &desiredFormat
91 93
 #endif
92 94
   CStdString     tmpDevice;
93 95
 
  96
+  if (driver == "PROFILER")
  97
+    TRY_SINK(Profiler);
  98
+
  99
+
94 100
 #ifdef _WIN32
95 101
 
96 102
   if ((driver.IsEmpty() && g_sysinfo.IsVistaOrHigher() && !g_advancedSettings.m_audioForceDirectSound) || driver == "WASAPI")
@@ -107,7 +113,7 @@ IAESink *CAESinkFactory::Create(CStdString &device, AEAudioFormat &desiredFormat
107 113
   #endif
108 114
   if (driver.IsEmpty() || driver == "OSS")
109 115
     TRY_SINK(OSS)
110  
-    
  116
+  
111 117
   /* no need to try others as both will have been attempted if driver is empty */
112 118
   if (driver.IsEmpty())
113 119
     return NULL;
1  xbmc/cores/AudioEngine/Makefile.in
@@ -14,6 +14,7 @@ SRCS = \
14 14
 	AESinkFactory.cpp \
15 15
 	Sinks/AESinkALSA.cpp \
16 16
 	Sinks/AESinkOSS.cpp \
  17
+	Sinks/AESinkProfiler.cpp \
17 18
 	\
18 19
 	Utils/AEChannelInfo.cpp \
19 20
 	Utils/AEConvert.cpp \
88  xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp
... ...
@@ -0,0 +1,88 @@
  1
+/*
  2
+ *      Copyright (C) 2005-2010 Team XBMC
  3
+ *      http://www.xbmc.org
  4
+ *
  5
+ *  This Program is free software; you can redistribute it and/or modify
  6
+ *  it under the terms of the GNU General Public License as published by
  7
+ *  the Free Software Foundation; either version 2, or (at your option)
  8
+ *  any later version.
  9
+ *
  10
+ *  This Program is distributed in the hope that it will be useful,
  11
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13
+ *  GNU General Public License for more details.
  14
+ *
  15
+ *  You should have received a copy of the GNU General Public License
  16
+ *  along with XBMC; see the file COPYING.  If not, write to
  17
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18
+ *  http://www.gnu.org/copyleft/gpl.html
  19
+ *
  20
+ */
  21
+
  22
+#include "system.h"
  23
+
  24
+#include "AESinkProfiler.h"
  25
+#include <stdint.h>
  26
+#include <limits.h>
  27
+
  28
+#include "Utils/AEUtil.h"
  29
+#include "utils/StdString.h"
  30
+#include "utils/log.h"
  31
+#include "utils/TimeUtils.h"
  32
+#include "settings/GUISettings.h"
  33
+
  34
+CAESinkProfiler::CAESinkProfiler() {
  35
+}
  36
+
  37
+CAESinkProfiler::~CAESinkProfiler()
  38
+{
  39
+}
  40
+
  41
+bool CAESinkProfiler::Initialize(AEAudioFormat &format, CStdString &device)
  42
+{
  43
+  if (AE_IS_RAW(format.m_dataFormat))
  44
+    return false;
  45
+
  46
+  format.m_dataFormat   = AE_FMT_FLOAT;
  47
+  format.m_frames       = 128;
  48
+  format.m_frameSamples = format.m_channelLayout.Count();
  49
+  format.m_frameSize    = format.m_frameSamples * sizeof(float);
  50
+  return true;
  51
+}
  52
+
  53
+void CAESinkProfiler::Deinitialize()
  54
+{
  55
+}
  56
+
  57
+bool CAESinkProfiler::IsCompatible(const AEAudioFormat format, const CStdString device)
  58
+{
  59
+  if (AE_IS_RAW(format.m_dataFormat))
  60
+    return false;
  61
+
  62
+  if (format.m_dataFormat != AE_FMT_FLOAT)
  63
+    return false;
  64
+
  65
+  return true;
  66
+}
  67
+
  68
+float CAESinkProfiler::GetDelay()
  69
+{
  70
+  return 0.0f;
  71
+}
  72
+
  73
+unsigned int CAESinkProfiler::AddPackets(uint8_t *data, unsigned int frames)
  74
+{
  75
+  int64_t ts = CurrentHostCounter();
  76
+  CLog::Log(LOGDEBUG, "CAESinkProfiler::AddPackets - latency %f ms", (float)(ts - m_ts) / 1000000.0f);
  77
+  m_ts = ts;
  78
+  return frames;
  79
+}
  80
+
  81
+void CAESinkProfiler::Drain()
  82
+{
  83
+}
  84
+
  85
+void CAESinkProfiler::EnumerateDevices (AEDeviceList &devices, bool passthrough)
  86
+{
  87
+  devices.push_back(AEDevice("Profiler", "Profiler"));
  88
+}
46  xbmc/cores/AudioEngine/Sinks/AESinkProfiler.h
... ...
@@ -0,0 +1,46 @@
  1
+#pragma once
  2
+/*
  3
+ *      Copyright (C) 2005-2010 Team XBMC
  4
+ *      http://www.xbmc.org
  5
+ *
  6
+ *  This Program is free software; you can redistribute it and/or modify
  7
+ *  it under the terms of the GNU General Public License as published by
  8
+ *  the Free Software Foundation; either version 2, or (at your option)
  9
+ *  any later version.
  10
+ *
  11
+ *  This Program is distributed in the hope that it will be useful,
  12
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14
+ *  GNU General Public License for more details.
  15
+ *
  16
+ *  You should have received a copy of the GNU General Public License
  17
+ *  along with XBMC; see the file COPYING.  If not, write to
  18
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19
+ *  http://www.gnu.org/copyleft/gpl.html
  20
+ *
  21
+ */
  22
+
  23
+#include "system.h"
  24
+
  25
+#include "Interfaces/AESink.h"
  26
+#include <stdint.h>
  27
+
  28
+class CAESinkProfiler : public IAESink
  29
+{
  30
+public:
  31
+  virtual const char *GetName() { return "Profiler"; }
  32
+
  33
+  CAESinkProfiler();
  34
+  virtual ~CAESinkProfiler();
  35
+
  36
+  virtual bool Initialize  (AEAudioFormat &format, CStdString &device);
  37
+  virtual void Deinitialize();
  38
+  virtual bool IsCompatible(const AEAudioFormat format, const CStdString device);
  39
+
  40
+  virtual float        GetDelay        ();
  41
+  virtual unsigned int AddPackets      (uint8_t *data, unsigned int frames);
  42
+  virtual void         Drain           ();
  43
+  static void          EnumerateDevices(AEDeviceList &devices, bool passthrough);
  44
+private:
  45
+  int64_t m_ts;
  46
+};

0 notes on commit fe7d0ca

Please sign in to comment.
Something went wrong with that request. Please try again.