History

An experiment in migrating RtAudio support to submodule.

In theory this makes it easier to maintain and upgrade. It also re-opens the possibility of building an ASIO variant for windows.

Dana Batali committed 4 years ago

Commit 052cf621 parent eef84ee6 files · +24 −76Browse files

Unified · Split

6 files
  1. .gitmodules +3 −0
  2. src/host/RtAudio/RtError.h +0 −60
  3. src/host/chuck_audio.cpp +9 −9
  4. src/host/chuck_audio.h +1 −1
  5. src/makefile +10 −6
  6. src/rtaudio +1 −0
.gitmodules+3−0
@@ -0,0 +1,3 @@
1+[submodule "src/rtaudio"]
2+ path = src/rtaudio
3+ url = https://github.com/thestk/rtaudio
src/host/RtAudio/RtError.h+0−60
@@ -1,60 +0,0 @@
1−/************************************************************************/
2−/*! \class RtError
3− \brief Exception handling class for RtAudio & RtMidi.
4−
5− The RtError class is quite simple but it does allow errors to be
6− "caught" by RtError::Type. See the RtAudio and RtMidi
7− documentation to know which methods can throw an RtError.
8−
9−*/
10−/************************************************************************/
11−
12−#ifndef RTERROR_H
13−#define RTERROR_H
14−
15−#include <exception>
16−#include <iostream>
17−#include <string>
18−
19−class RtError : public std::exception
20−{
21− public:
22− //! Defined RtError types.
23− enum Type {
24− WARNING, /*!< A non-critical error. */
25− DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
26− UNSPECIFIED, /*!< The default, unspecified error type. */
27− NO_DEVICES_FOUND, /*!< No devices found on system. */
28− INVALID_DEVICE, /*!< An invalid device ID was specified. */
29− MEMORY_ERROR, /*!< An error occured during memory allocation. */
30− INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
31− INVALID_USE, /*!< The function was called incorrectly. */
32− DRIVER_ERROR, /*!< A system driver error occured. */
33− SYSTEM_ERROR, /*!< A system error occured. */
34− THREAD_ERROR /*!< A thread error occured. */
35− };
36−
37− //! The constructor.
38− RtError( const std::string& message, Type type = RtError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
39−
40− //! The destructor.
41− virtual ~RtError( void ) throw() {}
42−
43− //! Prints thrown error message to stderr.
44− virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
45−
46− //! Returns the thrown error message type.
47− virtual const Type& getType(void) const throw() { return type_; }
48−
49− //! Returns the thrown error message string.
50− virtual const std::string& getMessage(void) const throw() { return message_; }
51−
52− //! Returns the thrown error message as a c-style string.
53− virtual const char* what( void ) const throw() { return message_.c_str(); }
54−
55− protected:
56− std::string message_;
57− Type type_;
58−};
59−
60−#endif
src/host/chuck_audio.cpp+9−9
@@ -157,7 +157,7 @@ void ChuckAudio::probe() · 156 unmodified lines
157157
158158 // allocate RtAudio
159159 try { audio = new RtAudio( ); }
160− catch( RtError err )
160+ catch( RtAudioError err )
161161 {
162162 // problem finding audio devices, most likely
163163 EM_error2b( 0, "%s", err.getMessage().c_str() );
@@ -175,7 +175,7 @@ void ChuckAudio::probe() · 11 unmodified lines
175175 for( int i = 0; i < devices; i++ )
176176 {
177177 try { info = audio->getDeviceInfo(i); }
178− catch( RtError & error )
178+ catch( RtAudioError & error )
179179 {
180180 error.printMessage();
181181 break;
@@ -215,7 +215,7 @@ t_CKUINT ChuckAudio::device_named( const std::string & name, t_CKBOOL needs_dac, · 33 unmodified lines
215215
216216 // allocate RtAudio
217217 try { audio = new RtAudio(); }
218− catch( RtError err )
218+ catch( RtAudioError err )
219219 {
220220 // problem finding audio devices, most likely
221221 EM_error2b( 0, "%s", err.getMessage().c_str() );
@@ -231,7 +231,7 @@ t_CKUINT ChuckAudio::device_named( const std::string & name, t_CKBOOL needs_dac, · 9 unmodified lines
231231 {
232232 // get info
233233 try { info = audio->getDeviceInfo(i); }
234− catch( RtError & error )
234+ catch( RtAudioError & error )
235235 {
236236 error.printMessage();
237237 break;
@@ -253,7 +253,7 @@ t_CKUINT ChuckAudio::device_named( const std::string & name, t_CKBOOL needs_dac, · 15 unmodified lines
253253 for( int i = 0; i < devices; i++ )
254254 {
255255 try { info = audio->getDeviceInfo(i); }
256− catch( RtError & error )
256+ catch( RtAudioError & error )
257257 {
258258 error.printMessage();
259259 break;
@@ -477,7 +477,7 @@ t_CKBOOL ChuckAudio::initialize( t_CKUINT num_dac_channels, · 217 unmodified lines
477477
478478 // allocate RtAudio
479479 try { m_rtaudio = new RtAudio( ); }
480− catch( RtError err )
480+ catch( RtAudioError err )
481481 {
482482 // problem finding audio devices, most likely
483483 EM_error2( 0, "%s", err.getMessage().c_str() );
@@ -731,7 +731,7 @@ t_CKBOOL ChuckAudio::initialize( t_CKUINT num_dac_channels, · 247 unmodified lines
731731 CK_RTAUDIO_FORMAT, sample_rate, &bufsize,
732732 cb, m_cb_user_data,
733733 &stream_options );
734− } catch( RtError err ) {
734+ } catch( RtAudioError err ) {
735735 // log
736736 EM_log( CK_LOG_INFO, "exception caught: '%s'...", err.getMessage().c_str() );
737737 EM_error2( 0, "%s", err.getMessage().c_str() );
@@ -882,7 +882,7 @@ t_CKBOOL ChuckAudio::start( ) · 144 unmodified lines
882882 m_rtaudio->startStream();
883883 m_start = TRUE;
884884 }
885− catch( RtError err )
885+ catch( RtAudioError err )
886886 {
887887 return FALSE;
888888 }
@@ -904,7 +904,7 @@ t_CKBOOL ChuckAudio::stop( ) · 15 unmodified lines
904904 m_rtaudio->stopStream();
905905 m_start = FALSE;
906906 }
907− catch( RtError err )
907+ catch( RtAudioError err )
908908 {
909909 return FALSE;
910910 }
src/host/chuck_audio.h+1−1
@@ -36,7 +36,7 @@ · 35 unmodified lines
3636
3737 #include "chuck_def.h"
3838 #include <string>
39−#include "RtAudio/RtAudio.h"
39+#include <RtAudio.h>
4040
4141
4242
src/makefile+10−6
@@ -2,6 +2,7 @@ DESTDIR?=/usr/local/bin · 1 unmodified line
22 COREDIR=core
33 HOSTDIR=host
44 CK_PLATFORM=
5+RTAUDIODIR=./rtaudio
56
67
78 ########################## DEFAULT MAKE TARGET #################################
@@ -155,8 +156,9 @@ LO_COBJS_CORE+= lo/address.o lo/blob.o lo/bundle.o lo/message.o lo/method.o \ · 147 unmodified lines
155156
156157
157158 ############################ CHUCK HOST TARGETS ################################
158−CXXSRCS_HOST+= RtAudio/RtAudio.cpp chuck_audio.cpp chuck_console.cpp \
159− chuck_main.cpp
159+CXXINC_HOST+= -I${RTAUDIODIR} -I${RTAUDIODIR}/include
160+CXXSRCS_HOST+= chuck_main.cpp chuck_audio.cpp chuck_console.cpp \
161+ ${RTAUDIODIR}/RtAudio.cpp
160162
161163
162164 ############################ OBJECT FILE TARGETS ###############################
@@ -208,16 +210,18 @@ chuck-core: · 45 unmodified lines
208210 make $(MAKECMDGOALS) -C $(COREDIR) $(ARCH_ARGS)
209211 @echo -------------
210212
213+CFLAGS_HOST= ${CFLAGS} -I${RTAUDIODIR}
214+CFLAGSDEPEND_HOST=${CFLAGSDEPEND} ${CFLAGS_HOST}
211215 chuck: chuck-core $(COBJS_HOST) $(CXXOBJS_HOST)
212216 $(LD) -o chuck $(OBJS) $(LDFLAGS) $(ARCHOPTS)
213217
214218 $(COBJS_HOST): %.o: %.c
215− $(CC) $(CFLAGS) $(ARCHOPTS) -c $< -o $@
216− @$(CC) -MM -MQ "$@" $(CFLAGSDEPEND) $< > $*.d
219+ $(CC) $(CFLAGS_HOST) $(ARCHOPTS) -c $< -o $@
220+ @$(CC) -MM -MQ "$@" $(CFLAGSDEPEND_HOST) $< > $*.d
217221
218222 $(CXXOBJS_HOST): %.o: %.cpp
219− $(CXX) $(CFLAGS) $(ARCHOPTS) -c $< -o $@
220− @$(CXX) -MM -MQ "$@" $(CFLAGSDEPEND) $< > $*.d
223+ $(CXX) $(CFLAGS_HOST) $(ARCHOPTS) -c $< -o $@
224+ @$(CXX) -MM -MQ "$@" $(CFLAGSDEPEND_HOST) $< > $*.d
221225
222226 clean:
223227 @rm -rf $(wildcard chuck chuck.exe) *.o *.d */*.{o,d} */*/*.{o,d} $(OBJS) \
src/rtaudio+1−0
@@ -0,0 +1 @@
1+Subproject commit f9fd8726ccb688baa43aaae642179a69d353f6d2

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t