~ubuntu-branches/ubuntu/wily/aegisub/wily-proposed

« back to all changes in this revision

Viewing changes to src/audio_player_portaudio.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Reichel, Pascal De Vuyst, Juan Picca, Sebastian Reichel
  • Date: 2015-08-04 21:40:50 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150804214050-y2aghm9vdksoc8t7
Tags: 3.2.2+dfsg-1
[ Pascal De Vuyst ]
* Fix Typo in package description (Closes: #739219)

[ Juan Picca ]
* Add patch to fix reproducible build (Closes: #789728)

[ Sebastian Reichel ]
* New upstream release
 - remove vendor directory from orig tarball
* Update Debian Standards Version to 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
/// @ingroup audio_output
33
33
///
34
34
 
35
 
 
36
 
#include "config.h"
37
 
 
38
35
#ifdef WITH_PORTAUDIO
39
 
 
40
 
#include <libaegisub/log.h>
41
 
 
42
36
#include "audio_player_portaudio.h"
43
37
 
44
38
#include "audio_controller.h"
45
39
#include "compat.h"
46
 
#include "include/aegisub/audio_provider.h"
47
40
#include "options.h"
48
41
#include "utils.h"
49
42
 
50
 
DEFINE_SIMPLE_EXCEPTION(PortAudioError, agi::AudioPlayerOpenError, "audio/player/open/portaudio")
 
43
#include <libaegisub/audio/provider.h>
 
44
#include <libaegisub/log.h>
 
45
#include <libaegisub/make_unique.h>
51
46
 
52
47
// Uncomment to enable extremely spammy debug logging
53
48
//#define PORTAUDIO_DEBUG
69
64
};
70
65
static const size_t pa_host_api_priority_count = sizeof(pa_host_api_priority) / sizeof(pa_host_api_priority[0]);
71
66
 
72
 
PortAudioPlayer::PortAudioPlayer(AudioProvider *provider) : AudioPlayer(provider) {
 
67
PortAudioPlayer::PortAudioPlayer(agi::AudioProvider *provider) : AudioPlayer(provider) {
73
68
        PaError err = Pa_Initialize();
74
69
 
75
70
        if (err != paNoError)
76
 
                throw PortAudioError(std::string("Failed opening PortAudio: ") + Pa_GetErrorText(err), 0);
 
71
                throw AudioPlayerOpenError(std::string("Failed opening PortAudio: ") + Pa_GetErrorText(err));
77
72
 
78
73
        // Build a list of host API-specific devices we can use
79
74
        // Some host APIs may not support all audio formats, so build a priority
86
81
        GatherDevices(Pa_GetDefaultHostApi());
87
82
 
88
83
        if (devices.empty())
89
 
                throw PortAudioError("No PortAudio output devices found", 0);
 
84
                throw AudioPlayerOpenError("No PortAudio output devices found");
90
85
 
91
86
        if (provider)
92
87
                OpenStream();
171
166
                }
172
167
        }
173
168
 
174
 
        throw PortAudioError("Failed initializing PortAudio stream: " + error, 0);
 
169
        throw AudioPlayerOpenError("Failed initializing PortAudio stream: " + error);
175
170
}
176
171
 
177
172
void PortAudioPlayer::paStreamFinishedCallback(void *) {
273
268
                for (auto it = player.devices.begin(); it != player.devices.end(); ++it)
274
269
                        list.push_back(to_wx(it->first));
275
270
        }
276
 
        catch (PortAudioError const&) {
 
271
        catch (AudioPlayerOpenError const&) {
277
272
                // No output devices, just return the list with only Default
278
273
        }
279
274
 
284
279
        return !!Pa_IsStreamActive(stream);
285
280
}
286
281
 
 
282
std::unique_ptr<AudioPlayer> CreatePortAudioPlayer(agi::AudioProvider *provider, wxWindow *) {
 
283
        return agi::make_unique<PortAudioPlayer>(provider);
 
284
}
 
285
 
287
286
#endif // WITH_PORTAUDIO